home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-09-23 | 1.3 KB | 53 lines | [TEXT/ttxt] |
- There is indeed a bug in SWCloneSprite. The frameArray field is
- no getting copied properly. Below is a fixed version. I haven't tested this
- at all, so be careful. Hope this helps.
-
- ...Tony
-
- SW_PASCAL OSErr SWCloneSprite(
- SpritePtr cloneSpriteP,
- SpritePtr* newSpriteP,
- void* spriteStorageP)
- {
- OSErr err;
- SpritePtr tempSpriteP;
- TimeTaskRec moveTimeTask, frameTimeTask;
- short frame;
- FramePtr *tempFrameArray;
-
- err = SWCreateSprite(&tempSpriteP, spriteStorageP,
- cloneSpriteP->maxFrames);
-
- if (err == noErr)
- {
- // save off the time tasks, these are unique to a particular sprite
- moveTimeTask = tempSpriteP->moveTimeTask;
- frameTimeTask = tempSpriteP->frameTimeTask;
-
- // copy the clone sprite into the temp sprite
- tempFrameArray = tempSpriteP->frameArray; // save off the frame
- array ptr
- *tempSpriteP = *cloneSpriteP;
- tempSpriteP->frameArray = tempFrameArray; // restore the frame
- array ptr
-
- // restore the time tasks
- tempSpriteP->moveTimeTask = moveTimeTask;
- tempSpriteP->frameTimeTask = frameTimeTask;
-
- // clear the next and prev fields, just in case
- tempSpriteP->nextSpriteP = NULL;
- tempSpriteP->prevSpriteP = NULL;
-
- // copy the frame array
- for (frame = 0; frame < tempSpriteP->maxFrames; frame++)
- {
- tempSpriteP->frameArray[frame] = cloneSpriteP->frameArray[frame];
- }
-
- *newSpriteP = tempSpriteP;
- }
-
- return err;
- }
-